package com.futureCloudMOM.controller.core.web.produce;

import com.futureCloudMOM.common.annotation.Log;
import com.futureCloudMOM.common.core.domain.AjaxResult;
import com.futureCloudMOM.common.core.page.TableDataInfo;
import com.futureCloudMOM.controller.core.controller.BaseApiController;
import com.futureCloudMOM.core.domain.ProduceDispatch;
import com.futureCloudMOM.core.service.ProduceDispatchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 文件名 ProduceDispatchController
 *
 * @since 2023/6/6 16:04
 */
@Api(tags = "派工单")
@RestController
@RequestMapping("produce/dispatch")
public class ProduceDispatchController extends BaseApiController<ProduceDispatch, ProduceDispatch, ProduceDispatchService> {

    public ProduceDispatchController(ProduceDispatchService service) {
        super(service);
    }


    @Log(title = "派工单调度")
    @ApiOperation("派工单调度")
    @PostMapping("/dispatchUpdate")
    public AjaxResult dispatchUpdate(@RequestBody ProduceDispatch produceDispatch){
        service.dispatchUpdate(produceDispatch);
        return success();
    }

    @Log(title = "派工单强制关闭")
    @ApiOperation("派工单强制关闭")
    @GetMapping("/forceStop/{id}")
    public AjaxResult forceStop(@PathVariable("id") Long id){
        service.forceStop(id);
        return success();
    }

    @Log(title = "根据生产工单ID查询派工单详情")
    @ApiOperation("根据生产工单ID查询派工单详情")
    @GetMapping("/dispatchListByBillTaskSubId/{id}")
    public TableDataInfo dispatchListByBillTaskSubId(@PathVariable("id") Long id){
        return getDataTable(service.dispatchListByBillTaskSubId(id));
    }


}
